package com.kabuda.blog.controller;

import com.kabuda.blog.service.TagService;
import com.kabuda.blog.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author kabuda
 * @create 2023-01-16 16:13
 */
@Api(tags = "标签控制层")
@RestController
@RequestMapping("/tags")
public class TagsController {
    @Autowired
    private TagService tagService;
    @ApiOperation("热点标签")
    @GetMapping("/hot")
    public Result hotTags(){
        //关联文章最多的六个标签
        int limit=6;
        return  tagService.hots(limit);
    }
    @ApiOperation("查找所有标签id和name")
    @GetMapping
    public Result findAll(){
        return tagService.findAll();

    }
    @ApiOperation("查找所有标签")
    @GetMapping("/detail")
    public Result findAllDetail(){
        return tagService.findAllDetail();
    }
    @ApiOperation("根据id查找所有标签")
    @GetMapping("/detail/{id}")
    public Result findAllDetailById(@PathVariable("id")Long id){
        return tagService.findAllDetailById(id);
    }
}
